#pragma once

#include "IProgress.h"
#include "Task.h"
// ProgressDlg dialog

class ProgressDlg : public CDialog, IProgress
{
	DECLARE_DYNAMIC(ProgressDlg)

public:
	ProgressDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~ProgressDlg();

// Dialog Data
	enum { IDD = IDD_PROGRESS };
	int RunTask(Task *aTask);

	void SetStatus(const std::wstring &aStatus);
	void ShowWarning(const std::wstring &aStatus);

	void SetTitle(const std::wstring &aTitle) { mTitle = aTitle.c_str(); }

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	BOOL OnInitDialog();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnDestroy();
	afx_msg void OnTimer(UINT_PTR nIDEvent);

	static unsigned long WINAPI Link(void *aParam);

	void Update();

	CStatic mStatusLabel;
	CBitmap mWheelBitmap;

	UINT_PTR mTimer;

	DWORD mWheelIndex;

private:

	CString mTitle;
	CString mStatus;
	CMutex mMutex;

	Task *mTask;

	HANDLE mThreadHandle;
};
